package demo1;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    //交替组 2
    public int numberOfAlternatingGroups(int[] colors, int k) {
        int slow = 0;
        int fast = 1;
        int pre = 0;
        int ans = 0;
        while(slow<colors.length){
            if(colors[pre%colors.length] == colors[fast%colors.length]){
                slow = fast;
            }
            if(fast-slow+1==k){
                slow++;
                ans++;

            }
            fast++;
            pre++;
        }
        return ans;
    }
}
